# -*- coding: utf-8 -*-
'''
Created on Apr 28, 2012

@author: LONG HOANG GIANG
'''
import os, sys
sys.path.append(os.path.join(__file__, '../'))
from CrawlerLib import commonlib
import gzip
import simplejson as json

file1 = '/home5/vietcntt/public_html/site-api-vietcntt/res/truyen/inu-yasha.data'
file2 = '/home5/vietcntt/public_html/site-api-vietcntt/res/truyen/inu-yasha-manga24.data'

fp = gzip.open(file1)
a = json.load(fp)
fp.close

fp = gzip.open(file2)
b = json.load(fp)
fp.close


r = []
for item in a:
    if 'Tập' in item['chapter']: continue
    r.append(item)
    
for item in r: a.remove(item)
a.reverse()

b.extend(a)
for item in b:
    print item['chapter']
fp = gzip.open("/home5/vietcntt/public_html/site-api-vietcntt/res/truyen/data", 'wb')
fp.write(json.dumps(b))
fp.close